﻿/// <reference path="../Jquery/jquery-1.4.4-vsdoc.js" />
/// <reference path="EasySite.js" />


var PageEditor = function () {

}

PageEditor.prototype.Init = function () {
    var istoCreate = $("input[name='Page.ID']").val() == "0";
    $("#btnSave").click(function () {
        $("#pageCategories select").removeAttr("name");
        $("#pageCategories select:last").attr("name", "PageCategoryID");
        EasySite.ajaxPostBusy("/Page/Save", $("#pageEditForm").serialize(), function (result) {
            if (result.Success) {
                $("input[name='Page.ID']").val(result.Value);
                alert("Success!");
                EasySite.ShowActionResultDialog("server returned message:", [
                    {
                        Text: "Edit this page",
                        Command: function () {
                            "Editing..."
                        }
                    }, {
                        Text: "Go back to pages list",
                        Command: function () {
                            alert("Going back...");
                        }
                    }
                ]);
            }
            else {
                alert("Error happened!");
            }
        }, "Saving...");
    });
    $("#btnBack").click(function () {
        window.location = "/Page";
    });

    $("#rdoUseView").click(function () {
        $("#rowView").show();
        $("#rowContent").hide();
    });
    $("#rdoUseContent").click(function () {
        $("#rowView").hide();
        $("#rowContent").show();
    });

    EasySite.InitActionResultDialog();
}